﻿@*TwoCheckoutPaymentProcessor*@

@if(ViewBag.Mode == "Place")
{
    <div class="hint">
        <p>@T(Res.Of(ViewBag.Mode).Name("Hint"))</p>
    </div>
}
else if(ViewBag.Mode == "Process")
{
    var attrs = (Model.Attributes as IEnumerable<dynamic>);
    string req = String.Format("{0}?sid={1}&fixed={2}&id_type={3}&lang={4}&cart_order_id={5}" +
        "&merchant_order_id={6}&total={7}&card_holder_name={8}&street_address={9}&street_address2={10}" +
        "&city={11}&state={12}&zip={13}&country={14}&email={15}&phone={16}", 
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "gateway").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "sid").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "fixed").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "id_type").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "lang").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "cart_order_id").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "merchant_order_id").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "total").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "card_holder_name").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "street_address").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "street_address2").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "city").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "state").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "zip").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "country").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "email").Value),
        JDM.String(attrs.Single(x => JDM.String(x.Key) == "phone").Value));
    if(attrs.Any(x => JDM.String(x.Key) == "demo"))
    {
        req = String.Format("{0}&demo={1}", req, JDM.String(attrs.Single(x => JDM.String(x.Key) == "demo").Value));
    }
    req = String.Format("{0}&x_receipt_link_url={1}", req, Url.Action(Loc.Act("IPN").Ctrl("Payment").Set(new
    {
        handlerID = "2cd39234-9ba5-4b0a-9104-46c3ed3b07d1"
    }).Localized().Proto("http")));
    if(!Svc.Config(Par.In("WebPortal").Name("DebugMode"), Context.IsDebuggingEnabled))
    {
        <script type="text/javascript">
            jQuery(document).ready(function() {
                setTimeout(function() {
                    window.location = '@req';
                }, 3000);
            });
        </script>
    }
    <div class="box">
        <section>
            <div class="hint">
                @if(Svc.Config(Par.In("WebPortal").Name("DebugMode"), Context.IsDebuggingEnabled))
                {
                    <p>@req</p>
                }
                <p>@T(Res.Of(ViewBag.Mode).Name("Hint"))</p>
            </div>
        </section>
    </div>
}